<template>
	<view>
		<u-sticky>
			<view class="tags"><u-tabs :list="list1" @click="click" width="300rpx"></u-tabs></view>
		</u-sticky>
		<view class="content">
				<view class="box" v-for="item in couponsList">
					<view class="box-top">
						<view class="box-two">
							<!-- <image style="width: 100rpx;height: 100rpx;" :src="item.headImg" mode=""></image>
							<view class="tuijian">{{item.id}}</view> -->
							
							<view class="" style="color: red;font-weight: 600;font-size: 40rpx;text-align: center;padding: 15rpx 0;">
								￥{{item.couponDenomination}}
							</view>
							<view class="" style="color: #999;font-size: 26rpx;text-align: center;">
								满￥{{item.howMuchFullMoney}}使用
							</view>
						</view>
						
						<view class="box-three">
							<view class="one">{{ item.couponName }}</view>
							<view class="two">
								总数{{item.number}}张/每人限领{{item.maxNumber}}张
							</view>
							<view class="two">
								已领取99张/已使用1张
							</view>
						</view>
					</view>
					<view class="box-bottom">
						<view class="con">
							使用期限：{{item.startTime}} ~ {{item.endTime}}
						</view>
						
					</view>
					
				</view>
		</view>
	</view>
</template>

<script>
import {searchPlugsCouponsList } from '../../../utils/api.js';
export default {
	data() {
		return {
			keyword: '',
			list1: [
				{
					id:-1,
					name: '正常'
				},
				{
					id:0,
					name: '已过期'
				},
				{
					id:1,
					name: '已领完 '
				}
			],
			couponsList: [],
			search: {
				page: 1,
				size: 10
			},
		};
	},
	onShow() {
		// this.getCategoryList();
		this.getCouponsList();
	},
	onReachBottom() {
		
		if(this.couponsList.length<this.total){
			this.search.page++;
			this.getCouponsList();
		}
		
	},
	methods: {
		click(item) {
			this.search.page=1;
			this.couponsList=[]
			this.getCouponsList();
		},
		
		searchlist() {
			this.getCouponsList();
			this.keyword = '';
		},
		getCouponsList() {
			let data = {
				page: this.search.page,
				size: this.search.size,
				adminId: uni.getStorageSync('userInfo').id,
				userServiceToken: uni.getStorageSync('userInfo').userServiceToken,
				keyword: this.keyword,
			};
			searchPlugsCouponsList(data).then(res => {
				if (res.code == 200) {
					if (this.search.page == 1) {
						this.couponsList = [];
					}
					let arr = [];
					arr = this.couponsList.concat(res.body.list);
					this.couponsList = arr;
					this.total=res.body.total
				}
			});
		},
	}
};
</script>
<style lang="scss">
page {
	background-color: #f5f5f5;
}
</style>
<style lang="scss" scoped>
page {
	background-color: #999;
}
.header {
	display: flex;
	align-items: center;
	padding: 20rpx;
	background-color: #fff;
	.button {
		width: 180rpx;
		height: 60rpx;
		.btn {
			color: #fff;
			height: 60rpx;
			line-height: 60rpx;
			font-size: 26rpx;
			background-color: #6da7ff;
			text-align: center;
		}
	}
}
.tags {
	background-color: #fff;
	/deep/.u-tabs__wrapper__nav__item {
		padding: 0 80rpx;
	}
}
.content {
	padding: 20rpx;
	.box {
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		background-color: #fff;
		padding: 20rpx;
		.box-top{
			display: flex;
			align-items: center;
			padding-bottom: 0rpx;
			border-bottom: 1rpx solid #f5f5f5;
			.box-two {
				width: 150rpx;
				height: 150rpx;
				margin-right: 30rpx;
				position: relative;
				border-radius: 10rpx;
				overflow: hidden;
				.tuijian {
					color: #fff;
					background-color: rgba(0, 0, 0, 0.3);
					height: 40rpx;
					width: 100%;
					font-size: 24rpx;
					text-align: center;
					line-height: 40rpx;
					
					position: absolute;
			
					
					left: 0;
					bottom: 0;
				}
				.xiajia{
					width: 150rpx;
					height: 150rpx;
					color: #fff;
					position: absolute;
					left: 0;
					top: 0;
					text-align: center;
					line-height: 150rpx;
				}
			}
			
			.box-three {
				.one {
					font-weight: 700;
				}
				.two {
					margin: 5rpx 0;
					display: flex;
					align-items: center;
					font-size: 26rpx;
					.text {
						font-size: 26rpx;
						width: 150rpx;
					}
				}
				
			}
		}
		.box-bottom{
			display: flex;
			align-items: center;
			padding-top: 20rpx;
			.con{
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				font-size: 22rpx;
				
			}
		}
		
	}
}
.footer {
	display: flex;
	align-items: center;
	padding: 20rpx;
	position: fixed;
	bottom: 0;
	background-color: #fff;
	width: 100%;
	.left {
		margin-right: 50rpx;
	}
	.right {
		background-color: #eff6ff;
		border: 1rpx solid #d1e5ff;
		// padding: 20rpx;
		border-radius: 30rpx;
		color: #016eff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.tet {
			padding: 15rpx 30rpx;
			border-right: 1rpx solid #d1e5ff;
		}
		.tet:nth-last-child(1) {
			border-right: none;
		}
	}
}
</style>
